<?php
require_once('./config.php');
require_once('database.php');
require_once('user.php');

$user = User::find_by_id($_GET['id']);
$fields = array();
$fields  = $_POST;	

if(isset($_POST['submit'])){
	$user->id = $_GET['id'];
	$update_user = $user->update($user->id, $fields);
	
	if($update_user){
	
		header("Location: " . $config['base_url'] . "home.php?action=read");

	}

}


?>

<form action="update.php?id=<?php echo $user->id; ?>" method="post">
	<label for="username">Username</label>
	<input type="text" name="username" value="<?php echo $user->username; ?>" />
	<label for="password">Password</label>
	<input type="password" name="password" value="<?php echo $user->password; ?>" />
	<input type="submit" value="Update" name="submit">
</form>